import 'package:demo1223/service/service_method.dart';
import 'package:flutter/material.dart';
import 'package:provide/provide.dart';
import '../provide/detailsDats.dart';
import './details_page/details_top.dart';
import './details_page/details_tabar.dart';
import './details_page/details_details.dart';
import './details_page/details_cart.dart';

class DetailsPage extends StatelessWidget {
  final String id;
  DetailsPage(this.id);
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          leading: IconButton(
            icon: Icon(Icons.arrow_back),
            onPressed: () {
              Navigator.pop(context);
            },
          ),
          title: Text('商品详情'),
        ),
        body: FutureBuilder(
          future: _getBackInfo(context),
          builder: (context, snapshot) {
            if (snapshot.hasData) {
              return Stack(
                children: <Widget>[
                  Container(
                    child: ListView(
                      children: <Widget>[
                        DetailsTop(),
                        DetailsTabbar(),
                        // DerailsWeb()
                      ],
                    ),
                  ),
                  Positioned(
                    bottom: 0,
                    left: 0,
                    child: DerailsCart(),
                  )
                ],
              );
            } else {
              return Text('加载中');
            }
          },
        ));
  }

  Future _getBackInfo(BuildContext context) async {
    print('====================++++++++++++++++++++++++++++');
    await Provide.value<DetailsInfoProvide>(context).getGoodsInfo(id);
    print('数据获取成功');
    print('====================++++++++++++++++++++++++++++');
    return '完成加载';
  }
}
